#!/bin/bash

set -e -u

# configure locale
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen
sed -i 's/#\(es_ES\.UTF-8\)/\1/' /etc/locale.gen
sed -i 's/#\(gl_ES\.UTF-8\)/\1/' /etc/locale.gen
sed -i 's/#\(pt_BR\.UTF-8\)/\1/' /etc/locale.gen
locale-gen

# configure root shell
usermod -s /usr/bin/zsh root

# configure sudo
chmod 750 /etc/sudoers.d
chmod 440 /etc/sudoers.d/g_wheel

# configure pacman
sed -i "s/#Server/Server/g" /etc/pacman.d/mirrorlist

# configure services
systemctl enable multi-user.target pacman-init.service choose-mirror.service NetworkManager.service

# configure live user and login
LIVE_USER=parabola
useradd -m -p "" -g users -G "adm,audio,floppy,log,network,rfkill,scanner,storage,optical,power,wheel" -s /usr/bin/zsh ${LIVE_USER}
cp -r /home/liveuser/. /home/${LIVE_USER}/
chown -R ${LIVE_USER}:users /home/${LIVE_USER}/
rm -rf /home/liveuser
# echo "@/home/${LIVE_USER}/.language.sh" >> /home/${LIVE_USER}/.config/lxsession/LXDE/autostart
sed -i "s/--autologin root/--autologin ${LIVE_USER}/" /etc/systemd/system/getty@tty1.service.d/autologin.conf
sed -i "s/_DATE_/${iso_version}/" /etc/motd

